<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" isELIgnored="false" %>
<%@ page import="com.lagou.edu.pojo.Resume" %>
<%@ page import="com.lagou.edu.dao.ResumeDao" %>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ page import="org.springframework.context.ApplicationContext" %>

<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%--    <%page isELlgored ="true"%>--%>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>

    <script type="text/javascript" src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
    <script type="text/javascript">
        $(function() {
            // alert($(this).attr("href"));
            // $(".delete").click(function(){
            //     var href = $(this).attr("href");
            //     $("form").attr("action",href).submit();
            //     return false;
            // })
        });
    </script>
</head>
<body>
<%
    ServletContext context = request.getSession().getServletContext();
    ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
    ResumeDao resumeDao = (ResumeDao)ctx.getBean("resumeDao");
    List<Resume> list = resumeDao.findAll();
    session.setAttribute("list",list);
    for (int i = 0; i < list.size(); i++){
        Resume resume = list.get(i);
        System.out.println(resume.getName()+1);
    }
%>
<table border="1" cellpadding="10" cellspacing="0">
    <tr>
        <td>ID</td>
        <td>Name</td>
        <td>address</td>
        <td>phone</td>
    </tr>
    <c:forEach items="${resumes }" var="resume" >
        <tr>
            <th>${resume.id }</th>
            <th>${resume.name }</th>
            <th>${resume.address }</th>
            <th>${resume.phone }</th>
            <th><a href="resume/${resume.id}">Edit</a></th>
            <th><a href="resume/delete/${resume.id}">Delete</a></th>

        </tr>
    </c:forEach>
</table>
</body>

<a href="resume">Add New Employee</a>
</html>